package com.rightrule.rule.fieldtask;

import com.rightrule.rule.constans.FieldSourceEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ComputingTaskFactory {

    @Autowired
    private AutoMappingTaskService autoMappingTaskService;

    @Autowired
    private ScriptTaskService scriptTaskService;

    @Autowired
    private SqlTaskService sqlTaskService;


    /**
     * 根据变量类型，获取对应的拉取服务
     *
     * @param source
     * @return
     */
    public ComputingTaskService getTaskService(FieldSourceEnum source) {
        switch (source) {
            case RPC_PULL:
                return autoMappingTaskService;
            case SCRIPT_EXECUTE:
                return scriptTaskService;
            case ODPS_OFFLINE_PULL:
                return sqlTaskService;
            default:
                return null;
        }
    }
}
